import { Module } from 'vuex'

interface AppState {
  sidebar: {
    opened: boolean
  }
}

const appModule: Module<AppState, any> = {
  namespaced: true,
  state: () => ({
    sidebar: {
      opened: true // 默认展开侧边栏
    }
  }),
  mutations: {
    TOGGLE_SIDEBAR: (state) => {
      state.sidebar.opened = !state.sidebar.opened
    }
  },
  actions: {
    toggleSidebar({ commit }) {
      commit('TOGGLE_SIDEBAR')
    }
  }
}

export default appModule